package com.fm.financemanage.service;

import com.fm.financemanage.constant.PlatTypeEnum;
import com.fm.financemanage.mapper.RsMemberRecordMapper;
import com.fm.financemanage.mapper.YbMemberRecordMapper;
import com.fm.financemanage.model.vo.PageVo;
import com.fm.financemanage.model.vo.memberrecord.RsMemberRecordListVo;
import com.fm.financemanage.model.vo.memberrecord.YbMemberRecordListVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MemberRecordService {

    @Resource
    private RsMemberRecordMapper rsMemberRecordMapper;

    @Resource
    private YbMemberRecordMapper ybMemberRecordMapper;

    public PageVo<List<RsMemberRecordListVo>> getRsList(String uuid, String type, Integer state,Integer accountantId, Integer companyId, String certno, Integer page, Integer limit) {

        return new PageVo<List<RsMemberRecordListVo>>(rsMemberRecordMapper.getList(null,uuid, type,state, accountantId, companyId, certno, (page - 1) * limit, limit),
                rsMemberRecordMapper.count(null,uuid, type,state, accountantId, companyId, certno));
    }

    public PageVo<List<YbMemberRecordListVo>> getYbList(String uuid, String type, Integer state, Integer accountantId, Integer companyId, String certno, Integer page, Integer limit) {
        return new PageVo<List<YbMemberRecordListVo>>(ybMemberRecordMapper.getList(null,uuid, type,state, accountantId, companyId, certno, (page - 1) * limit, limit),
                ybMemberRecordMapper.count(null,uuid, type,state, accountantId, companyId, certno));
    }

    public void remove(String uuid, String type, Integer id) {
        if(PlatTypeEnum.fj_RS.getType().equals(type)){
            rsMemberRecordMapper.removeByUserIdAndId(null,uuid,id);
        }else{
            ybMemberRecordMapper.removeByUserIdAndId(null,uuid,id);
        }
    }
}
